package com.xxx.video.main.adapters;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.xxx.video.R;
import com.xxx.video.commen.adapters.BaseRecycleViewAdapter;
import com.xxx.video.commen.adapters.BaseViewHolder;
import com.xxx.video.commen.utils.ResourcesUtils;
import com.xxx.video.main.beans.IndexBean;

import butterknife.BindView;

public class HomeFragmentBannerItemAdapter extends BaseRecycleViewAdapter<IndexBean.CarouselListBean, HomeFragmentBannerItemAdapter.MyHolder> {


    public HomeFragmentBannerItemAdapter(@NonNull Context context) {
        super(context);
    }

    @Override
    public MyHolder onCreateDefaultViewHolder(View view, int viewType) {
        return new MyHolder(view);
    }

    @Override
    public int getItemLayout(int viewType) {
        return R.layout.item_home_fragment_banner_item;
    }


    class MyHolder extends BaseViewHolder {

        @BindView(R.id.iv_item_home_fragment_banner)
        ImageView ivItemHomeFragmentBanner;

        public MyHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void setData2View(int position) {
            try {
                IndexBean.CarouselListBean carouselListBean = getItem(position);
                Glide.with(context).load(ResourcesUtils.getInstance().getImagePath(carouselListBean.fCarouselpicUrl))
                        .apply(new RequestOptions()
                                .error(R.drawable.bg_place_holder_nine_five)
                                .placeholder(R.drawable.bg_place_holder_nine_five))
                        .into(ivItemHomeFragmentBanner);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
